package com.mars.diancan.converter;

import com.mars.diancan.dto.OrderDTO;
import com.mars.diancan.pojo.OrderMaster;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * OrderMaster to OrderDTO 转换器
 * @author MARS
 * @date 2018/6/25
 */
public class OrderMaster2OrderDTOConverter {

    public static OrderDTO converter(OrderMaster orderMaster){
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(orderMaster,orderDTO);
        return orderDTO;
    }

    public static List<OrderDTO> converter(List<OrderMaster> orderMasterList){
        List<OrderDTO> orderDTOList = new ArrayList<>();
        orderDTOList =  orderMasterList.stream().map(e -> converter(e)).collect(Collectors.toList());
        return orderDTOList;
    }
}
